<?php
    session_start();
    if(isset($_SESSION['user'])){
        header("Location: actions.php");
    }
?>
<html>
    <body>


<?php
    /*Includes*/
    session_start();
    include('sessions.php');

    /*Reading all the vars*/
    foreach($_POST as $key => $value){
        ${$key} = $value;
    }
    
    if($user && $clave){
        //echo "<br />int the if";
        if(loggin($user, $clave)){
            echo "<br />good";
            $_SESSION['user'] = $user;
            header("Location: actions.php");
        }else{
            echo "<br />User could not log in. Please Try Again.";
            header("Location: index.php");
            exit();
        }
    }
?>
        <br />
        <a href="logout.php">Salir</a>
        <br />
        <a href="index.php">Inicio</a>
    </body>
</html>

